package com.cyl.manager.oms.domain.dto;
import java.math.BigDecimal;
import java.math.MathContext;
import java.math.RoundingMode;

import com.cyl.h5.service.H5OrderService;
 
public class BigDecimalExample {

    public static void main(String[] args) {
    	 BigDecimal payAmount = new BigDecimal("8.99");
    System.out.println(getFeeAmount(payAmount));
    }
    
    private final static BigDecimal payRate = new BigDecimal("0.006");//费率

    private static BigDecimal getFeeAmount(BigDecimal payAmount){
    	if(payAmount==null) {
            throw new RuntimeException("支付金额不能为空");
    	}
    	if (payAmount.compareTo(BigDecimal.ZERO) < 0) {
            throw new RuntimeException("支付金额不能小于0");
        } 
        return payAmount.multiply(payRate).setScale(2, RoundingMode.HALF_UP);
    }
    
}

